package fr.pascal.composite;

public class Leaf implements IComponent {

	private final String name;
	private String innerText;

	public Leaf(String name, String innerText) {
		this.name = name;
		this.innerText = innerText;
	}

	public void print(int depth) {
		String spaces = "";
		while (depth-- > 0) {
			spaces += " ";
		}
		System.out.println(String.format("%s<%s>", spaces, name));
		System.out.println(String.format("%s    %s", spaces, innerText));
		System.out.println(String.format("%s</%s>", spaces, name));
	}
}
